package ui.activity.profit.presenter;


import javax.inject.Inject;

import base.BaseBiz;
import ui.activity.profit.biz.ProfitBiz;
import ui.activity.profit.contract.ProfitContract;
import ui.model.ProfitBean;
import ui.model.ProfitNewBean;

/**
 * Created by chenjian on 19/2/26
 */

public class ProfitPresenter implements ProfitContract.Presenter {

    ProfitContract.View view;
    ProfitBiz profitBiz;


    @Inject
    public ProfitPresenter(ProfitContract.View view) {
        this.view = view;
    }


    @Override
    public void setBiz(BaseBiz biz) {
        profitBiz = (ProfitBiz) biz;
    }


    @Override
    public void getInfo(final boolean isRefresh, String customId, String strDate) {
        if (isRefresh) {
//            list.clear();
        }
        view.loading(true);
        profitBiz.GetInComeDetail(customId, strDate, new BaseBiz.Callback<ProfitBean>() {
            @Override
            public void onSuccess(ProfitBean info) {
                view.upDateUI(info);
                view.loading(false);
            }

            @Override
            public void onFailure(ProfitBean info) {
                view.loading(false);
            }
        });
    }

    @Override
    public void getTopInfo(int year, int month, int day) {
        profitBiz.GetInComeDetailNew(year, month,day, new BaseBiz.Callback<ProfitNewBean>() {
            @Override
            public void onSuccess(ProfitNewBean info) {
                view.upDateTopUI(info);
                view.loading(false);
            }

            @Override
            public void onFailure(ProfitNewBean info) {
                view.loading(false);
            }
        });
    }


}
